var e = require;
var t = module;
var c,
    i = (c = e("LListView")) && c.__esModule ? c : {default: c};
cc.Class({
    extends: cc.Component,
    properties: {listViewRoot: cc.Node, pbListView: cc.Prefab, nodeTop: cc.Node, lvRoot: cc.Node},
    onDestroy: function onDestroy() {
        this.winTimeout && clearTimeout(this.winTimeout);
    },
    start: function start() {
        var e = this;
        this.level = lGlobal.curLevel;
        var t = lGlobal.lvCfg.json[lGlobal.curModel][lGlobal.curLevel],
            c = lGlobal.modelBundles[lGlobal.curModel];
        if (c) {
            var o = t.lv;
            c.load("data/" + o + "/dds", cc.Prefab, function (t, c) {
                if (t) console.log(t);
                else {
                    var o = cc.instantiate(c);
                    (o.parent = e.lvRoot),
                        (e.listViewRoot = cc.find("bottom/listViews", o)),
                        (e.nodeTop = cc.find("top", o)),
                        (e.slv1 = e.listViewRoot._children[0].getComponent(i.default)),
                        (e.slv2 = e.listViewRoot._children[1].getComponent(i.default)),
                        (e.slv3 = e.listViewRoot._children[2].getComponent(i.default)),
                        (e.listView1SelectIndex = 0),
                        (e.listView2SelectIndex = 0),
                        (e.listView3SelectIndex = 0),
                        (e.listView1SelectWord = ""),
                        (e.listView2SelectWord = ""),
                        (e.listView3SelectWord = ""),
                        e.slv1.setSelectCB(function (t, c) {
                            (e.listView1SelectIndex = t),
                                c && (e.listView1SelectWord = c.getComponent(cc.Label).string);
                        }),
                        e.slv2.setSelectCB(function (t, c) {
                            (e.listView2SelectIndex = t),
                                c && (e.listView2SelectWord = c.getComponent(cc.Label).string);
                        }),
                        e.slv3.setSelectCB(function (t, c) {
                            (e.listView3SelectIndex = t),
                                c && (e.listView3SelectWord = c.getComponent(cc.Label).string);
                        }),
                        (e.ddsLabel = cc.find("3/label", e.nodeTop).getComponent(cc.Label)),
                        (e.answer = cc.find("answer", o).getComponent(cc.Label).string),
                        (e.ddsAni = o.getComponent(cc.Animation)),
                        e.ddsAni.play("start");
                }
            });
        }
    },
    onSubmitClick: function onSubmitClick() {
        var e = this,
            t = this.listView1SelectWord + this.listView2SelectWord + this.listView3SelectWord;
        this.ddsLabel.string = t;
        for (var c = t, i = !1, o = 0; o < this.ddsAni._clips.length; o++) {
            if (this.ddsAni._clips[o].name == c) {
                i = !0;
                break;
            }
        }
        i || (c = t == this.answer ? "win" : "lose"),
            this.ddsAni.play(c),
            t == this.answer
                ? (soundMgr.playSound(soundMgr.right),
                  (this.winTimeout = setTimeout(function () {
                      window.ui.win({model: "DropDownSelect", lv: e.level});
                  }, 2500)))
                : soundMgr.playSound(soundMgr.wrong);
    }
});
